<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWxWorkChatDataTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wx_work_chat_data', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('seq')->default(0)->comment('消息的seq值，标识消息的序号');
            $table->string('msgid')->unique()->comment('消息id，消息的唯一标识，企业可以使用此字段进行消息去重。');
            $table->text('from_userid')->nullable()->comment('发送者userid');
            $table->text('msg')->nullable()->comment('明文消息，json格式');
            $table->text('data')->comment('加密数据，json格式，即chatdata里的每一项数据');
            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `wx_work_chat_data` comment '企业微信会话内容'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_work_chat_data');
    }
}
